<?php 
	//判断用户是否登录
	session_start();
	if(isset($_SESSION['managerInfo'])){
		//用户已经登录
	} else {
		//跳转到登录界面
		header("Location:http://localhost/SelectCoursesSystem/RegisterLogin.php");
	}
	/* if(!defined('APP')) die('error!'); */
?>
<?php
require_once dirname(__FILE__).'/../../controller/ManagerController.class.php';
?>	
<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<title>欢迎进入学生选课系统(管理员)</title>	
	</head>
	<link rel="stylesheet" href="../../css/student_view.css" type="text/css"/>
	<link rel="stylesheet" href="../../css/manager_view.css" type="text/css">
	<link rel="stylesheet" href="../../css/course_reviese_view.css" type="text/css">
	<link rel="stylesheet" href="../../css/model.css" type="text/css">
	<body>
		<!-- 标题头 -->
		<div class="main_head_class">
			<div class="main_head_show_class">
				<p>欢迎您进入学生选课系统</p>
			</div>
		</div>
		<!-- 背景面板 -->
		<div class="main_student_info_class">
			<!-- 管理员信息 -->
			<div class="student_info_class">
				<!-- 头像以及头像背景图 -->
				<div class="student_info_head_class">
					<!-- 头像上背景颜色 -->
					<div class="student_info_head_first">
					</div>
					<div class="student_info_head_img_class">
						<img alt="" src="../../images/head.jpg">
					</div>
				</div>
				<!-- 对于选修课(增加、修改、删除、查找)的操作 -->
				<div class="student_operator_class">
					<ul>
						<li><p class="IAmSuper_class">(我是普通管理员)</p>
						<li><a href="./ManagerView.php">查看课程信息</a></li>
						<li><a href="./ManagerView.php?operation=add&object=course&courseOrStudentId=unknown">新增课程信息</a>
						<!-- <li><a href="javascript:void(0)">查看学生信息</a></li> -->
					</ul>
				</div>
			</div>
			<!-- 课程对应的选课信息 -->
			<div class="main_student_courses_info">
				<div class="student_courses_info_backgroud">
					<div class="student_courses_info">
						<!-- 根据参数(操作[operation]、对象[object]、唯一标识参数[courseOrStudentId])显示不同界面 -->
						<?php 
							//获取参数(操作、对象、唯一标识参数)
							$operation = isset($_GET['operation']) ? $_GET['operation'] : "";
							$object = isset($_GET['object']) ? $_GET['object'] : "";
							$courseOrStudentId= isset($_GET['courseOrStudentId']) ? $_GET['courseOrStudentId'] : "";
							
							$managerController = new ManagerController();
							if($operation === "" || $object === "" || $courseOrStudentId === ""){
								//现在所有课程信息
								//echo "$operation"."**"."$object"."**".$courseOrStudentId;
								require_once dirname(__FILE__).'/ShowCoursesOperator.php';					
							}else if($operation === 'delete' && $object === 'course'){ //执行删除
								//删除课程
								$managerController->deleteCourse($courseOrStudentId);
								//刷新界面
								header("Location:http://localhost/SelectCoursesSystem/view/manager/ManagerView.php");
							} else if($operation === 'revise' && $object === 'course'){		//修改课程
								//修改课程
								require_once dirname(__FILE__).'/CourseReviseView.php';
							} else if($operation === 'add' && $object === 'course' && $courseOrStudentId === 'unknown'){
								//新增课程
								require_once dirname(__FILE__).'/AddCourseView.php';
							}
							?>
					</div>
				</div>
			</div>	
		</div>
	</body>
</html>